<!--
 * @Description: 病虫害记录
-->
<template>
  <BaseMainSlot>
    <template v-slot:btn-box>
      <Selectbutton
        :buttonselectlist="selectbutlist"
        @nowselectbuttonindex="gettabletype"
      />
      <ActionBar
        :page-no="14"
        :add-active="addActive"
        :del-active="delActive"
        :edit-active="editActive"
        :cancel-active="cancelActive"
        :save-active="saveActive"
        :has-edit="false"
        :has-edit-column="true"
        :has-export="searchlist.result == 1"
        @showColumn="showColumn"
        @download="download"
        @add="add"
        @cancel="cancel"
        @edit="edit"
        @del="del"
        @save="save"
      />
    </template>
    <template v-slot:search-box>
      <SearchForm :formConfig="formConfig" :formData="searchlist" @search="search"></SearchForm>
    </template>
    <template v-slot:table-box>
      <Table @sortChange="changeTableSort" :propList="tableColumn" v-loading="loading" :listData="tableData" :showSelectColumn="false">
        <template v-slot:operation="{ row }">
          <template v-if="!row.index">
            <el-button
              v-if="judgePermission(14, 'edit') && searchlist.result === 2"
              class="text-btn-cursor"
              type="text"
              size="small"
              @click="edits(row)"
            >
              <i class="el-icon-edit-outline"></i> 修 改
            </el-button>
            <el-button
              v-if="searchlist.result === 2"
              class="text-btn-cursor"
              type="text"
              size="small"
              @click="handle(row)"
            >
              处 理
            </el-button>
            <el-button
              v-if="judgePermission(14, 'del')"
              class="text-btn-cursor cursor-delete"
              type="text"
              size="small"
              @click="delmessage(row)"
            >
              <i class="el-icon-delete"></i> 删除
            </el-button>
          </template>
        </template>
        <template v-slot:disposeDate="{ row, item }">
          <template v-if="!row.index">
            {{ dateToFormat(row[item.prop]) }}
          </template>
        </template>
        <template v-slot:disposeAction="{ row }">
          <template v-if="!row.index">
            <div v-if="row.disposeAction === 2" style="color:#e01c1c;">其他</div>
            <div v-if="row.disposeAction === 1" style="color:#2ce01c;">处理完成</div>
          </template>
        </template>
        <template v-slot:img="{ row, item }">
          <template v-if="!row.index">
            <el-button
              v-if="row[item.prop]"
              type="success"
              @click="getpicmessage(row[item.prop])"
            >点击查看</el-button>
            <span v-else>暂无图片</span>
          </template>
        </template>
        <template v-slot:facilityNoList="{ row }">
          <template v-if="!row.index">
            <el-button
              class="text-btn-cursor"
              type="text"
              size="small"
              @click="checkFacility(row)"
            >
              <i class="el-icon-view"></i> 查看
            </el-button>
          </template>
        </template>
      </Table>
      <Pagination
        :page-size="pageSize"
        :current-page="currentPage"
        :total-size="totalSize"
        @changePageSize="changePageSize"
        @changeCurrentPage="changeCurrentPage"
      />
    </template>
    <template v-slot:dialog>
      <el-dialog
        :title="titleText + farmingTypeTitles + '记录'"
        :visible.sync="dialogFormVisible"
        width="55%"
        @close="cancel"
      >
        <el-form
          ref="formData"
          label-position="left"
          :model="formData"
          :rules="rules"
          class="el-form"
        >
          <el-form-item label="种植设施:" v-if="titleText != '处理'" class="w50p" prop="facilityNoList">
            <el-select
              v-model="formData.facilityNoList"
              multiple
              collapse-tags
              filterable
              clearable
              @change="changeFacilityNo"
            >
              <el-option
                v-for="item in facilityList"
                :key="item.facilityNo"
                :label="item.facilityName"
                :value="item.facilityNo"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            label="选择批次: "
            prop="alarmBatchNo"
            class="w50p"
          >
            <el-select
              v-model="formData.alarmBatchNo"
              clearable
              filterable
              @change="batch"
            >
              <el-option
                v-for="(item, index) in batchList"
                :key="index"
                :label="item.batchName"
                :value="item.batchNo"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            :label="`${farmingTypeTitles}类别: `"
            prop="alarmTypeName"
            class="w50p"
          >
            <el-select
              v-model="formData.alarmTypeName"
              clearable
              filterable
              placeholder="请选择"
              @change="getPestInfo"
            >
              <el-option
                v-for="(item, index) in (farmingTypeTitles === '病害'?alarmTypeLists:alarmTypeList)"
                :key="index"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            :label="`${farmingTypeTitles}名称: `"
            prop="alarmDes"
            class="w50p"
          >
            <el-select
              v-model="formData.alarmDes"
              clearable
              filterable
              placeholder="请选择"
            >
              <el-option
                v-for="(item, index) in alarmDesList"
                :key="index"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            :label="`${farmingTypeTitles}图片：`"
            class="w50p"
          >
            <ele-upload-image
              v-model="image1"
              :response-fn="handleResponse"
              :before-remove="handleRemove"
              :headers="headers"
              :file-size="10"
              :action="ImageUrl()"
            />
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            label="发现日期："
            prop="insectDate"
            class="w50p"
          >
            <el-date-picker
              v-model="formData.insectDate"
              type="datetime"
              clearable
            />
          </el-form-item>
          <el-form-item
            v-if="titleText != '处理'"
            label="是否处理完成: "
            prop="disposeAction"
            class="w50p"
          >
            <el-select v-model="formData.disposeAction" clearable>
              <el-option
                v-for="handtypeitem in handingtypeList"
                :key="handtypeitem.id"
                :label="handtypeitem.name"
                :value="handtypeitem.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="formData.disposeAction === 1"
            label="处理图片："
            class="w50p"
          >
            <ele-upload-image
              v-model="image2"
              :response-fn="handleResponse2"
              :before-remove="handleRemove2"
              :headers="headers"
              :file-size="10"
              :action="ImageUrl()"
            />
          </el-form-item>
          <el-form-item
            v-if="formData.disposeAction === 1"
            label="处理日期："
            prop="disposeDate"
            class="w50p"
          >
            <el-date-picker
              v-model="formData.disposeDate"
              type="datetime"
              clearable
            />
          </el-form-item>
          <el-form-item
            v-if="formData.disposeAction === 1"
            label="备注: "
            prop="insectDisposeDes"
            class="w50p"
          >
            <el-input
              v-model="formData.insectDisposeDes"
              clearable
            />
          </el-form-item>
        </el-form>
        <span
          slot="footer"
          class="dialog-footer"
        >
          <el-button
            class="zh-button-one"
            @click="cancel"
          >取 消</el-button>
          <el-button
            class="zh-button-two"
            type="primary"
            @click="save"
          >确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog
        title="图片"
        :visible.sync="showpicview"
        width="55%"
        v-loading="imgloading"
      >
        <img
          v-for="item,index in pictviewurl"
          :key="index"
          style="width: 100%;"
          :src="`data:image/png;base64,${item.pictureData}`"
        />
        <span
          slot="footer"
          class="dialog-footer"
        >
          <el-button
            class="zh-button-one"
            @click="showpicview = false"
          >取 消</el-button>
          <el-button
            class="zh-button-two"
            type="primary"
            @click="showpicview = false"
          >确 定</el-button>
        </span>
      </el-dialog>
      <!-- 信息处理弹框 -->
      <el-dialog
        :title="`处理${farmingTypeTitles}`"
        :visible.sync="isshowhandleview"
        width="55%"
      >
        <div>
          <div style="width:100%;display:flex;color:#fff;height:40px;line-height:40px;">
            <div style="width:120px;">是否需要处理:</div>
            <el-select
              v-model="handlemessage.disposeFlag"
              :placeholder="'选择是否需要处理'"
            >
              <el-option
                v-for="disposeActionitem in disposeActionList"
                :key="disposeActionitem.id"
                :label="disposeActionitem.name"
                :value="disposeActionitem.id"
              />
            </el-select>
          </div>
          <div
            v-if="handlemessage.disposeFlag === 2"
            style="width:100%;display:flex;color:#fff;height:40px;line-height:40px;"
          >
            <div style="width:120px;">操作处理:</div>
            <el-select v-model="handlemessage.disposeAction">
              <el-option
                v-for="handtypeitem in handingtypeList"
                :key="handtypeitem.id"
                :label="handtypeitem.name"
                :value="handtypeitem.id"
              />
            </el-select>
          </div>
          <div
            v-if="handlemessage.disposeAction === 2"
            style="width:100%;display:flex;color:#fff;height:40px;line-height:40px;"
          >
            <div style="width:120px;">请输入:</div>
            <div style="width:50%">
              <el-input v-model="handlemessage.insectDisposeDes" />
            </div>
          </div>
        </div>
        <span
          slot="footer"
          class="dialog-footer"
        >
          <el-button
            class="zh-button-one"
            @click="isshowhandleview = false"
          >取 消</el-button>
          <el-button
            class="zh-button-two"
            type="primary"
            @click="handlemessagemet()"
          >确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog
        id="tableColumnDialog"
        title="配置列"
        :visible.sync="dialogTableColumnVisible"
      >
        <tableColumn
          v-if="dialogTableColumnVisible"
          ref="tableColumn"
          :tableColumn="allTableColumn"
          @cancelColumn="cancelColumn"
        />
        <div slot="footer" class="dialog-footer">
          <el-button class="zh-button-one" @click="dialogTableColumnVisible = false">
            取 消
          </el-button>
          <el-button
            class="zh-button-two"
            type="primary"
            @click="saveColumn"
          >
            保 存
          </el-button>
        </div>
      </el-dialog>
      <el-dialog title="设施列表" :visible="facilityDialogVisible" :before-close="()=>{facilityDialogVisible = false}">
        <div class="facility-list">
          <div v-for="(item,index) in batchFacilityMapperList" :key="index" class="facility-item">
            <div class="info-line"><div class="name">设施编号：</div><div class="value">{{ item.facilityNo }}</div></div>
            <div class="info-line"><div class="name">设施名称：</div><div class="value">{{ item.facilityName }}</div></div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button class="zh-button-one" @click="facilityDialogVisible = false">
            关 闭
          </el-button>
        </div>
      </el-dialog>
    </template>
  </BaseMainSlot>
</template>

<script>
import SearchForm from '@/components/searchForm';
import Table from '@/components/table/table.vue';
import userApi from "@/api/user/index"
import ActionBar from "@/components/ActionBar";
import Pagination from "@/components/Pagination";
import managementtwo from "@/api/digital-production/agr-input-management/agr-input-managementtwo";
import nowpagereq from "@/api/digital-production/pest-management/pest-zhalarm/index";
import pestInfoApi from "@/api/basic-info-manage/pest-info/index";
import BaseMainSlot from "@/components/BaseMainSlot/newBaseMainSlot.vue";
import Selectbutton from "@/components/selectbutton/index.vue";
import { mymixin } from "@/utils/mixins";
import { mapGetters } from "vuex";
import { farmingTypeTitle } from "@/utils/validate";
import { getToken } from "@/utils/auth";
import baseURL from "@/api/baseURL";
export default {
  name: "PestRecords",
  components: { SearchForm, Table, ActionBar, Pagination, BaseMainSlot, Selectbutton },
  mixins: [mymixin],
  data() {
    var farmingTypeTitles = farmingTypeTitle()
    return {
      tableColumn: [
        { prop: 'alarmBatchName', label: '批次名称', minWidth: '180' },
        { prop: 'alarmBatchNo', label: '批次号', minWidth: '120' },
        { prop: 'facilityNoList', label: '发现设施', minWidth: '120', slotName: 'facilityNoList' },
        { prop: 'alarmTypeName', label: farmingTypeTitles+'类别' },
        { prop: 'alarmDes', label: farmingTypeTitles+'名称' },
        // { prop: 'alarmDes', label: farmingTypeTitles+'信息' },
        // { prop: 'alarmStartDate', label: '告警开始时间', slotName: 'disposeDate' },
        // { prop: 'disposeMan', label: '告警处理人' },
        // { prop: 'disposeDate', label: '判断处理时间', slotName: 'disposeDate' },
        // { prop: 'lesses', label: '承租户' },
        // { prop: 'disposeAction', label: '状态', slotName: 'disposeAction' },
        { prop: 'pictureId', label: farmingTypeTitles+'图片', slotName: 'img' },
        { prop: 'insectDate', label: '发现日期', slotName: 'disposeDate', width: '185' },
        { prop: 'disposePictureId', label: '处理图片', slotName: 'img' },
        { prop: 'insectDisposeDes', label: '备注' },
        { prop: 'operation', label: '操作', slotName: 'operation', width: "170" }
      ],
      formConfig: [
        {
        //   label: '状态',
        //   prop: 'result',
        //   type: 'selectbutton',
        //   options: [
        //     { itemTypeId: 2, itemTypeName: "待处理" },
        //     { itemTypeId: 1, itemTypeName: "处理完成" },
        //   ],
        // }, {
          label: '批次选择',
          prop: 'batchNo',
          type: 'select',
          options: [], // batchList
          optionKey: { label: 'batchName', value: 'batchNo' }
        }, {
          label: farmingTypeTitles+'类别',
          prop: 'alarmType',
          type: 'select',
          options: [
            { label: '病害', value: 0 },
            { label: '虫害', value: 1 },
          ],
          optionKey: { label: 'label', value: 'value' }
        }, {
          label: '记录时间',
          prop: 'date',
          type: 'daterange',
        },
      ],
      selectbutlist: [
        { name: "未处理", value: 2 },
        { name: "已处理", value: 1 }
      ],
      facilityDialogVisible: false,
      batchFacilityMapperList: [],
      showpicview: false,
      pictviewurl: "",
      newtotalSize: 0,
      farmingTypeTitles: farmingTypeTitle(),
      // 是否有异常
      isAlarmList: [
        { name: "正常", value: 0 },
        { name: "异常", value: 1 }
      ],
      // 异常原因
      alarmTypeList: [
        { name: "病害", value: 0 },
        { name: "虫害", value: 1 }
      ],
      // 异常原因
      alarmTypeLists: [{ name: "病害", value: 0 }],
      // -------
      // 当前物联数据日期选择
      zhdateList: "",
      // 当前选中的病虫害图片id
      nowsectpictureid: "",
      state1: "",
      // 处理类别选择
      handingtypeList: [
        { name: "已处理", id: 1 },
        { name: "未处理", id: 2 }
      ],
      // 是否需要处理
      disposeActionList: [
        { name: "还未处理", id: 1 },
        { name: "是", id: 2 },
        { name: "否", id: 3 }
      ],
      // 可选择批次列表
      batchList: [],
      isshowhandleview: false,
      handlemessage: {
        insectAlarmId: "",
        disposeAction: "", // 处理类别
        disposeFlag: "", // 是否需要处理
        insectDisposeDes: "" // 虫害处理信息
      },
      alarmDesList: [],
      // 可选择所有地块
      facilityList: [],
      // 所搜索框内容
      searchlist: {
        result: 2
      },
      pickerOptionsone: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            }
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            }
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            }
          }
        ]
      },
      rules: {
        facilityNoList: [
          { required: true, message: "请选择种植设施", trigger: "change" }
        ],
        alarmBatchNo: [
          { required: true, message: "请选择批次", trigger: "change" }
        ],
        alarmTypeName: [
          { required: true, message: "请选择病虫害类别", trigger: "change" }
        ],
        alarmDes: [
          { required: true, message: "请选择病虫害名称", trigger: "change" }
        ],
        alarmType: [
          { required: true, message: "请选择"+farmingTypeTitles+"类别", trigger: "change" }
        ],
        disposeAction: [
          { required: true, message: "请选择是否处理完成", trigger: "change" }
        ],
        disposeDate: [
          { required: true, message: "请选择处理日期", trigger: "change" }
        ]
      },
      // 上传图片
      image1: '',
      image2: '',
      imgloading: false
    };
  },
  computed: {
    ...mapGetters({
      judgePermission: "permission/judgePermission"
    })
  },
  watch: {
    dialogFormVisible(v) {
      if (v) {
        this.$nextTick(()=>{
          this.$refs.formData?.clearValidate()
        })
      }
    }
    // nowChanceStau(newval) {
    //   this.getselectdatalist()
    //   this.nowplantTypeName = "种养类别"
    // }
  },
  created() {
    this.getfacilityList();
    this.getPestInfo();
  },
  mounted() {
    this.getTableDataList();
    this.getselectdatalist();
  },
  methods: {
    // 图片地址
    ImageUrl() {
      if (this.nowChanceStau === "edit" || this.nowChanceStau === "add") {
        return `${baseURL.webServiceUrl}v3/patrol/picture/addMultipart`;
      } else {
        return "#";
      }
    },
    handleResponse(res) {
      if (this.nowChanceStau === "edit" || this.nowChanceStau === "add") {
        this.formData.pictureId = res.data;
        pestInfoApi.queryPicture(res.data).then(res => {
          this.image1 = "data:image/png;base64," + res.data.pictureData;
        });
        return this.image1;
      } else {
        return this.$message.error("点击修改按钮再进行编辑!");
      }
    },
    handleRemove() {
      if (this.nowChanceStau === "edit" || this.nowChanceStau === "add") {
        this.formData.pictureId = ''
      } else {
        return this.$message.error("点击修改按钮再进行编辑!");
      }
    },
    // 
    handleResponse2(res) {
      if (this.nowChanceStau === "edit" || this.nowChanceStau === "add") {
        this.formData.disposePictureId = res.data;
        pestInfoApi.queryPicture(res.data).then(res => {
          this.image2 = "data:image/png;base64," + res.data.pictureData;
        });
        return this.image2;
      } else {
        return this.$message.error("点击修改按钮再进行编辑!");
      }
    },
    handleRemove2() {
      if (this.nowChanceStau === "edit" || this.nowChanceStau === "add") {
        this.formData.disposePictureId = ''
      } else {
        return this.$message.error("点击修改按钮再进行编辑!");
      }
    },
    // contractImg(param) {
    //   // pictureId
    //   if (typeof(param) === 'object') {
    //     console.log(param)
    //   }
    // },
    // contractImg2(param) {
    //   // disposePictureId
    //   if (typeof(param) === 'object') {
    //     console.log(param)
    //   }
    // },
    gettabletype(i) {
      this.searchlist.result = this.selectbutlist[i]?.value
      let list = ['insectDisposeDes', 'disposePictureId']
      list.map(el => {
        let index = this.tableColumn.findIndex(ele => { return ele.prop == el })
        if (index !== -1) {
          this.tableColumn[index].hide = i === 0
        }
      })
      this.search()
    },
    checkFacility(row) {
      let list = []
      row.facilityNoList.map(el => {
        let index = this.facilityList.findIndex(ele => {
          return el === ele.facilityNo
        })
        list.push({ facilityNo: el, facilityName: this.facilityList[index].facilityName })
      })
      this.batchFacilityMapperList = list
      this.facilityDialogVisible = true;
    },
    async changeFacilityNo(e) {
      this.batchList = [];
      this.formData.alarmBatchNo = '';
      let params = {
        no: e.join(','),
        batchStatus: 0,
      };
      let res = await managementtwo.findByFacilityNos(params);
      this.batchList = res.data;
    },
    // 获取设施选择框数据
    getfacilityList() {
      userApi.getfacilityAll({
        organizationList: sessionStorage.getItem("organizationList").split(","),
        farmingTypeNo: sessionStorage.getItem("farmingTypeNo"),
      }).then(res => {
        this.facilityList = res.data;
      });
    },
    getPestInfo(no) {
      this.$set(this.formData, 'alarmDes', '')
      pestInfoApi.queryByCondition({
        alarmTypeName: no
      }).then(res => {
        if (res.code !== 1) return
        this.alarmDesList = res.data;
      })
    },
    batch(e) {
      let obj = this.batchList.find(item => item.batchNo === e);
      // console.log(obj)
      this.$set(this.formData, "alarmBatchName", obj.batchName);
      this.$set(this.formData, "lessesNo", obj.lesseeNo);
      this.$set(this.formData, "lesses", obj.lesseeName);
    },
    // 获取下拉框数据
    getselectdatalist() {
      // 获取所有批次
      nowpagereq.getallbatchList({ status: 0 }).then(res => {
        this.batchList = res.data;
        this.formConfig[0].options = res.data;
      });
    },
    // 导出
    async download() {
      let params = {
        entity: {
          ...this.entity,
        }
      }
      let url = 'v3/patrol/insectAlarm/download'
      let excel = this.farmingTypeTitles+'记录表'
      this.downloadExcel(url, params, excel)
    },
    // 表格查询
    getTableDataList() {
      this.loading = true;
      this.tableData = [];
      let params = {
        page: this.currentPage,
        size: this.pageSize,
        sortList: this.sortList || [],
        entity: {
          // disposeAction: 1,
          organizationNo: getToken("organizationNo"),
          alarmBatchId: this.searchlist.batchNo || undefined,
          disposeAction: this.searchlist.result,
          alarmType: this.searchlist.alarmType
        }
      };
      if (this.searchlist.date) {
        params.entity.startTime = new Date(this.searchlist.date[0]);
        params.entity.endTime = new Date(this.searchlist.date[1]);
      }
      this.entity = params.entity
      nowpagereq.getlist(params).then(res => {
        if (res.code === 1) {
          // this.$message.success('查询成功')
        } else {
          this.$message.error("查询失败");
        }
        this.loading = false;
        let data = res.data;
        // 赋值总条数
        this.totalSize = data.totalElements;
        // 赋值数组
        this.tableData = data.content;
        this.addblankmet();
        this.resetActionBar();
      });
    },
    // 获取图片详情
    getpicmessage(id) {
      this.showpicview = true;
      this.imgloading = true;
      pestInfoApi.queryPictureList(id).then(res => {
        this.pictviewurl = res.data
        this.imgloading = false;
      });
    },
    search() {
      this.currentPage = 1;
      this.getTableDataList();
    },
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.getTableDataList();
    },
    changeCurrentPage(currentPage) {
      this.currentPage = currentPage;
      this.getTableDataList();
    },
    edits(e) {
      this.formData = { ...e, alarmType: e.alarmTypeName };
      this.nowChanceStau = "edit";
      this.titleText = "修改";
      this.dialogFormVisible = true;
      this.canInput = true;
      this.addActive = false;
      this.delActive = false;
      this.saveActive = true;
      this.cancelActive = true;
      this.editActive = false;
      this.image1 = ''
      this.image2 = ''
      this.formData.pictureId && pestInfoApi.queryPicture(this.formData.pictureId).then(res => {
        this.image1 = "data:image/png;base64," + res.data.pictureData;
      });
      this.formData.disposePictureId && pestInfoApi.queryPicture(this.formData.disposePictureId).then(res => {
        this.image2 = "data:image/png;base64," + res.data.pictureData;
      });
    },
    // 处理告警
    handle(e) {
      this.formData = { ...e, alarmType: e.alarmTypeName, disposeAction: 1 };
      this.nowChanceStau = "edit";
      this.titleText = "处理";
      this.dialogFormVisible = true;
      this.canInput = true;
      this.addActive = false;
      this.delActive = false;
      this.saveActive = true;
      this.cancelActive = true;
      this.editActive = false;
    },
    // 删除时触发方法
    delmessage(e) {
      // nowpagereq.dellist(e.insectAlarmId).then(res => {
      //   if (res.code === 1) {
      //     this.$message.success(res.msg || "删除成功！");
      //     this.search();
      //   } else {
      //     this.$message.error(res.msg || "删除失败！");
      //   }
      // });
      this.$confirm("此操作将永久删除该条数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        customClass: "myClass"
      })
        .then(() => {
          nowpagereq.dellist(e.insectAlarmId).then(res => {
            if (res.code === 1) {
              this.$message.success("删除成功");
              this.getTableDataList();
            } else {
              this.$message.error("删除失败");
            }
          });
        })
        .catch(() => {
          //
          this.$message("取消删除");
        });
    },
    // 展示处理弹框
    showdighandleview(e) {
      this.isshowhandleview = true;
      this.handlemessage = {
        insectAlarmId: e.insectAlarmId,
        disposeAction: "", // 处理类别
        disposeFlag: "", // 是否需要处理
        insectDisposeDes: "" // 虫害处理信息
      };
    },
    handlemessagemet() {
      if (
        this.handlemessage.disposeAction === 2 &&
        this.handlemessage.insectDisposeDes.length === 0
      ) {
        this.$message.warning("请填写信息！");
        return;
      }
      let params = {
        ...this.handlemessage
      };
      nowpagereq.editlist(params).then(res => {
        if (res.code === 1) {
          this.$message.success("处理成功");
          this.getTableDataList();
          this.isshowhandleview = false;
        } else {
          this.$message.warning("处理失败");
        }
      });
    },
    save(formData) {
      this.$refs["formData"].validate(valid => {
        if (valid) {
          if (this.nowChanceStau === "edit") {
            nowpagereq.editByAlarmlist(this.formData).then(res => {
              if (res.code === 1) {
                this.$message.success(res.msg || "修改成功！");
                this.search();
              } else {
                this.$message.error(res.msg || "修改失败！");
              }
            });
          } else if (this.nowChanceStau === "add") {
            nowpagereq.addlist({ ...this.formData }).then(res => {
              if (res.code === 1) {
                this.$message.success(res.msg || "新增成功！");
                this.search();
              } else {
                this.$message.error(res.msg || "新增失败！");
              }
            });
          }
        } else {
          // console.log('error submit!!');
          return false;
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.facility-list{
  display: flex;
  justify-content: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  .facility-item{
    width: 400px;
    max-width: 30%;
    min-width: 30%;
    margin-right: 3%;
    margin-bottom: 10px;
    // height: 80px;
    border-radius: 5px;
    // border: 1px solid #ccc;
    box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.15);
    padding: 10px 20px;

    .info-line{
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
      font-size: 14px;
      &:not(:last-child){
        margin-bottom: 10px;
      }
      .name{
        text-align: left;
        width: 80px;
        flex-shrink: 0;
      }
      .value{
        width: 100%;
        text-align: left;
        font-weight: normal;
      }
    }
  }
}
::v-deep .el-checkbox {
  .el-checkbox__label {
    color: #dbe9e9;
    color: #d3e01c;
    // flex-direction: column;
  }
}
::v-deep .el-dialog {
  .el-dialog__header .el-dialog__title {
    color: #dbe9e9;
  }
  background-color: #005d7b;
  border: #23fff8 1px solid;
  white-space: nowrap;
  ::v-deep .el-input__inner {
    color: #dbe9e9 !important;
  }
}
// ::v-deep .el-dialog .el-select .el-input__inner {
// color: #dbe9e9 !important;
// }

::v-deep .tab-select {
  width: 100%;
  .butt-list-sty {
    position: absolute;
    left: 5px;
    top: 7px;
  }
}
td {
  ::v-deep &>div{
    width: 100% !important;
  }
}
::v-deep .el-image__error {
  display: none;
}
::v-deep .el-upload__tip {
  display: none;
}
</style>
